













class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
    @classmethod
    def get_token(cls, user):
        token = super().get_token(user)
        token['is_staff'] = user.is_staff
        token['username'] =user.username

        token['name'] = user.name

        if user.clazz:
            token['className']=user.clazz.name
        else:
            token['className'] = '暂无班级'
        if user.is_superuser:
            token['roleName'] = '超级管理员'

        elif user.role:
            token['roleName'] = user.role.name
        else:
            token['roleName'] = '普通用户'
        if user.tel:
            token['tel'] = user.tel[3] + '****' + user.tel[-4:]
        else:
            token['tel'] = '暂无'

        return token



